<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: red;
            margin: 100px auto;
        }

        .box1 {
            width: 100px;
            height: 100px;
            background-color: rebeccapurple;
            margin: 100px auto;
        }

        .fade-enter {
            opacity: 0;
            transform: translate(-300px) rotate(360deg) scale(0.5);
        }

        .fade-enter-active,
        .fade-leave-active {
            transition: all .5s;
        }

        .fade-leave-to {
            transform: translateY(300px) rotate(180deg);
            opacity: 0;
        }

        button {
            display: inline-block;
            position: absolute;
            top: 0;
            left: 0;
           
        }

        #app>div:first-child {
            width: 100px;
            height: 80px;
            margin: 80px auto;
            position: relative;
            /* background-color: red; */
        }

        .btn-leave-active {
            transition: all 0.5s;
        }

        .btn-enter-active {
            transition: all .5s;
        }

        .btn-leave-to {
            opacity: 0;
            transform: translateX(-50px);
        }

        .btn-enter {
            opacity: 1;
            transform: translateX(50px);
        }
    
    </style>
</head>

<body>

    <div id="app">
        <div>
            <transition name='btn' mode='in-out'>
                <button key='3' v-if='isShow' @click='sisShow'>消失</button>
                <button v-else @click='xclick'>显示</button>
            </transition>
        </div>
        <transition name='fade' mode="out-in">
            <div key='1' class="box" v-if="isShow"></div>
        </transition>
    </div>



    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.13/dist/vue.js"></script>

    <script>
        const vm = new Vue({
            el: '#app',
            data: {
                isShow: true
            },
            methods: {
                sisShow() {
                    this.isShow = false
                    
                },
                xclick() {
                    this.isShow = true
                }
            }
        })

    </script>
</body>

</html>